// pages/previewImage/previewImage.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [{
      src: 'https://th.bing.com/th/id/OIP.Zte3ljd4g6kqrWWyg-8fhAHaEo?w=285&h=180&c=7&r=0&o=5&pid=1.7',
      checked: false,
      scale: 1,
    }, {
      src: 'https://th.bing.com/th/id/OIP.Zte3ljd4g6kqrWWyg-8fhAHaEo?w=285&h=180&c=7&r=0&o=5&pid=1.7',
      checked: false,
      scale: 1,
    }, {
      src: 'https://th.bing.com/th/id/R.f40ba86561918519b95431a5921e4f5d?rik=9AIbo9AhOYel0w&riu=http%3a%2f%2fwww.quazero.com%2fuploads%2fallimg%2f131210%2f1-131210210248.jpg&ehk=v81JiWKphT%2baLBzbhrxRkTUUwwnhJ5F2PFkm4xn4nEM%3d&risl=&pid=ImgRaw&r=0',
      checked: false,
      scale: 1,
    }],
    scale: 1,
    current: 0,
    showPreviewImage: false
  },
  changeCurrent(e) {
    this.setData({
      current: e.detail.current
    })
  },
  swiperAnimationfinish() {
    console.log("动画结束");
  },
  previewImage(e) {
    this.setData({
      current: e.target.dataset.index,
      showPreviewImage: true
    })
  },

  changeChecked(e) {
    console.log(this);
    const list = this.data.list.map((item, i) => {
      return {
        ...item,
        checked: e.target.dataset.index === i ? !item.checked : item.checked
      }
    })
    this.setData({
      list
    })
  },

  closePreviewImage() {
    this.setData({
      showPreviewImage: false
    })
  },

  onScale(e) {
    this.setData({
      scale: e.detail.scale,
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})